home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / modules / text.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-06-29  |  7.8 KB  |  260 lines

  1. function addLink(mc)
  2. {
  3.    Links[mc.link] = mc;
  4. }
  5. function getMCfromLink(Item)
  6. {
  7.    var _loc1_ = Item;
  8.    if(Links[_loc1_] == null)
  9.    {
  10.       var _loc2_ = [];
  11.       while(_loc1_ != sideMenu.ItemHome)
  12.       {
  13.          _loc2_.unshift(_loc1_._name.split("_").pop());
  14.          _loc1_ = _loc1_._parent._parent;
  15.       }
  16.       var _loc3_ = _loc2_.join("/");
  17.       Links[_loc1_] = Links[_loc3_];
  18.    }
  19.    return Links[_loc1_];
  20. }
  21. function removeLinkListener()
  22. {
  23.    Tardis.sideMenu.EB.removeListener(this);
  24. }
  25. function loadImage(mc, node, extrapath)
  26. {
  27.    var _loc3_ = extrapath;
  28.    if(_loc3_ == null)
  29.    {
  30.       _loc3_ = "";
  31.    }
  32.    var strDefaultPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
  33.    var _loc1_ = node.firstChild.nodeValue;
  34.    var _loc2_ = node.attributes.path;
  35.    if(_loc2_ != null)
  36.    {
  37.       _loc1_ = _loc2_ + _loc1_;
  38.    }
  39.    else
  40.    {
  41.       _loc1_ = strDefaultPath + _loc3_ + _loc1_;
  42.    }
  43.    if(strPathPrefix == null)
  44.    {
  45.       strPathPrefix = "";
  46.    }
  47.    mc.loadMovie(strPathPrefix + _loc1_);
  48. }
  49. function init()
  50. {
  51.    build();
  52.    _visible = true;
  53. }
  54. function build()
  55. {
  56.    var _loc2_ = Tardis.ActiveSection.id;
  57.    var _loc1_ = Tardis.Colors;
  58.    strSECTION_COLOR = _loc1_.getString(_loc2_);
  59.    SECTION_COLOR = _loc1_.getHex(_loc2_);
  60.    strSECTION_COLOR50 = _loc1_.getString(_loc2_ + "50");
  61.    SECTION_COLOR50 = _loc1_.getHex(_loc2_ + "50");
  62.    DEFAULT_COLOR = _loc1_.getHex("default");
  63.    DEFAULT_COLOR50 = _loc1_.getString("default50");
  64.    modWidth = nodeData.byName("dimensions").attributes.width;
  65.    txtWidth = modWidth - 15;
  66.    modHeight = nodeData.byName("dimensions").attributes.height;
  67.    OFFSET = Number(nodeData.byName("dimensions").attributes.offset);
  68.    showText();
  69. }
  70. function showText()
  71. {
  72.    SCROLLBOX_INIT_POS = 50 + OFFSET;
  73.    TEXT_POS = 3 + OFFSET;
  74.    CONTENT_POS = 0;
  75.    titleFF._width = txtWidth;
  76.    title2FF._width = txtWidth + 15;
  77.    if(nodeData.byName("title").getText() != null || nodeData.byName("title2").getText() != null || nodeData.byName("title3").getText() != null)
  78.    {
  79.       var _loc2_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("title").getText() + "</FONT> ";
  80.       _loc2_ += "<FONT COLOR=\"" + strSECTION_COLOR50 + "\"> " + nodeData.byName("title2").getText() + "</FONT> ";
  81.       _loc2_ += "<FONT COLOR=\"" + DEFAULT_COLOR50 + "\"> " + nodeData.byName("title3").getText() + "</FONT> ";
  82.       titleFF.htmlText = _loc2_;
  83.       titleFF._y = TEXT_POS;
  84.       titleFF.resize();
  85.       TEXT_POS += Math.ceil(titleFF._height - 3);
  86.    }
  87.    var strByline = nodeData.byName("byline").getText();
  88.    if(strByline != null)
  89.    {
  90.       title2FF.htmlText = strByline;
  91.       title2FF.textColor = DEFAULT_COLOR;
  92.       title2FF.autoSize = "left";
  93.       title2FF._y = TEXT_POS;
  94.       TEXT_POS += Math.ceil(title2FF._height - 3);
  95.    }
  96.    var strRating = nodeData.byName("rating").getText();
  97.    if(strRating.length > 0)
  98.    {
  99.       TEXT_POS += 2;
  100.       var mcR = this.attachMovie("clp_rating","mc_rating",++depth,{str:strRating,clr:SECTION_COLOR,_x:10,_y:TEXT_POS});
  101.       TEXT_POS += Math.ceil(mcR._height + 3);
  102.    }
  103.    this.attachMovie("scrollContentMC","sMC",++depth);
  104.    sMC.bodyFF._width = sMC.body2FF._width = txtWidth - 5;
  105.    var _loc3_ = nodeData.byName("body");
  106.    if(_loc3_.getText() != null)
  107.    {
  108.       sMC.bodyFF.htmlText = parseBoldTags(_loc3_.getText());
  109.       sMC.bodyFF.textColor = DEFAULT_COLOR;
  110.       sMC.bodyFF.autoSize = true;
  111.       sMC.bodyFF._y = CONTENT_POS;
  112.       CONTENT_POS += Math.ceil(sMC.bodyFF._height + 12);
  113.    }
  114.    var ndBody2 = nodeData.byName("body2");
  115.    if(ndBody2.getText() != null)
  116.    {
  117.       sMC.body2FF.htmlText = parseBoldTags(ndBody2.getText());
  118.       sMC.body2FF.textColor = DEFAULT_COLOR;
  119.       sMC.body2FF.autoSize = true;
  120.       sMC.body2FF._y = CONTENT_POS;
  121.       CONTENT_POS += Math.ceil(sMC.body2FF._height + 12);
  122.    }
  123.    var _loc1_ = nodeData.byName("bodylink");
  124.    if(_loc1_.byName("title").getText() != null)
  125.    {
  126.       bodyLinkMC.contentFF.htmlText = _loc1_.byName("title").getText();
  127.       bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  128.       bodyLinkMC.contentFF.autoSize = true;
  129.       bodyLinkMC.navLink = false;
  130.       if(_loc1_.attributes.link != null)
  131.       {
  132.          bodyLinkMC.link = _loc1_.attributes.link;
  133.          bodyLinkMC.navLink = true;
  134.       }
  135.       else
  136.       {
  137.          bodyLinkMC.link = _loc1_.byName("link").getText();
  138.          if(_loc1_.byName("link").attributes.type == "print")
  139.          {
  140.             bodyLinkMC.printable = true;
  141.             bodyLinkMC.arrowMC._visible = false;
  142.          }
  143.       }
  144.       bodyLinkMC.arrowMC._x = bodyLinkMC.contentFF._width + 1;
  145.       bodyLinkMC.btn._width = bodyLinkMC.contentFF._width + bodyLinkMC.arrowMC._width;
  146.    }
  147.    else
  148.    {
  149.       bodyLinkMC.arrowMC._visible = false;
  150.       bodyLinkMC.btn._width = sMC.bodyLinkMC.btn._height = 0;
  151.       bodyLinkMC.btn.enabled = false;
  152.       bodyLinkMC.contentFF._height = 0;
  153.    }
  154.    if(sMC._height > modHeight - bodyLinkMC.contentFF._height - TEXT_POS + 10)
  155.    {
  156.       this.attachMovie("FScrollPaneSymbol","contentScroll",++depth);
  157.       attachMovie("MaskerMC","MaskerMC",++depth);
  158.       contentScroll._x = 6;
  159.       contentScroll._y = TEXT_POS;
  160.       contentScroll.setSize(modWidth - 6,modHeight - bodyLinkMC.contentFF._height - TEXT_POS);
  161.       contentScroll.setHScroll(false);
  162.       contentScroll.setScrollContent(sMC);
  163.       MaskerMC._x = 6;
  164.       MaskerMC._y = TEXT_POS - MaskerMC._height + 10;
  165.       MaskerMC._width = contentScroll._width - 17;
  166.       MaskerMC._height = 5;
  167.       TEXT_POS += contentScroll._height + 5;
  168.       title2FF._width = txtWidth;
  169.       title2FF.autoSize = "left";
  170.    }
  171.    else
  172.    {
  173.       sMC.bodyFF._width += 10;
  174.       sMC.bodyFF.autoSize = true;
  175.       sMC._x = 8;
  176.       sMC._y = TEXT_POS;
  177.       TEXT_POS = modHeight - bodyLinkMC._height + 14;
  178.    }
  179.    bodyLinkMC._y = TEXT_POS;
  180.    onComplete();
  181. }
  182. function parseBoldTags(str)
  183. {
  184.    var _loc1_ = str;
  185.    var _loc2_ = _loc1_.indexOf("<b>");
  186.    if(_loc2_ != -1)
  187.    {
  188.       var _loc3_ = _loc1_.indexOf("</b>");
  189.       var word = _loc1_.substring(_loc2_ + 3,_loc3_);
  190.       var beginning = _loc1_.substring(0,_loc2_);
  191.       var end = _loc1_.substring(_loc3_ + 4);
  192.       return beginning + "<font face=\'FranklinGotURWTDem\'>" + word + "</font>" + parseBoldTags(end);
  193.    }
  194.    return _loc1_;
  195. }
  196. function txtOver(mc)
  197. {
  198.    Tardis.sideMenu.doOver(mc.link);
  199.    bodyLinkMC.contentFF.textColor = SECTION_COLOR;
  200.    bodyLinkMC.arrowMC.gotoAndStop("over");
  201. }
  202. function txtOut(mc)
  203. {
  204.    Tardis.sideMenu.doOut(mc.link);
  205.    bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  206.    bodyLinkMC.arrowMC.gotoAndStop("off");
  207. }
  208. function txtUp(mc)
  209. {
  210.    var _loc1_ = mc;
  211.    if(_loc1_.navLink)
  212.    {
  213.       Tardis.sideMenu.doUp(_loc1_.link);
  214.    }
  215.    else if(_loc1_ == bodyLinkMC && bodyLinkMC.printable)
  216.    {
  217.       printImage(_loc1_.link);
  218.    }
  219.    else
  220.    {
  221.       Tardis.webPageOpen(_loc1_.link,"_blank");
  222.    }
  223. }
  224. function doOver(mc)
  225. {
  226.    bodyLinkMC.contentFF.textColor = SECTION_COLOR;
  227.    bodyLinkMC.arrowMC.gotoAndStop("over");
  228. }
  229. function doOut(mc)
  230. {
  231.    bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  232.    bodyLinkMC.arrowMC.gotoAndStop("off");
  233. }
  234. function setRating(strRating, hxColor, clip)
  235. {
  236.    var _loc2_ = strRating;
  237.    var _loc1_ = new Color(clip.mc_dots);
  238.    _loc1_.setRGB(hxColor);
  239.    _loc2_ = "l_" + _loc2_.replace(".","_");
  240.    clip.mc_dots.gotoAndStop(_loc2_);
  241. }
  242. Links = {};
  243. Tardis.sideMenu.EB.addListener(this);
  244. _visible = false;
  245. stop();
  246. onReady();
  247. depth = 0;
  248. bodyLinkMC.btn.onRollOver = function()
  249. {
  250.    this._parent._parent.txtOver(this._parent);
  251. };
  252. bodyLinkMC.btn.onRollOut = function()
  253. {
  254.    this._parent._parent.txtOut(this._parent);
  255. };
  256. bodyLinkMC.btn.onRelease = function()
  257. {
  258.    this._parent._parent.txtUp(this._parent);
  259. };
  260.